function addcount (ent,ply)
	local class = ent:GetClass()
	local plyuni = ply:UniqueID()
	Msg("1")
	if table.HasValue(servertable["ply"][plyuni]["count"]["entitylist"],class) then
			Msg("2")
		for index, entityclass in ipairs(servertable["ply"][plyuni]["count"]["entitylist"]) do 
			if (entityclass == class) then
					Msg("3")
				servertable["ply"][plyuni]["count"]["countlist"][index] = servertable["ply"][plyuni]["count"]["countlist"][index] +1
				return 
			end
		end
	else
		Msg("bla")
		table.insert(servertable["ply"][plyuni]["count"]["entitylist"],class)
		table.insert(servertable["ply"][plyuni]["count"]["countlist"],1)
	end
end

local meta = FindMetaTable("Entity")
local oldremove = meta.Remove
function  meta:Remove( )
  removecount( self )
  oldremove( self )
end 

function removecount(ent)
	local entid = ent:EntIndex( )
	if ent:IsValid() then
		if servertable[entid] then
			if servertable[entid]["owner"] then
				local class = ent:GetClass()
				if servertable["ply"][plyuni]["count"]["entitylist"] then
					for index, entityclass in ipairs(servertable["ply"][plyuni]["count"]["entitylist"]) do 
						if (entityclass == class) then
							servertable["ply"][plyuni]["count"]["countlist"][index] = servertable["ply"][plyuni]["count"]["countlist"][index] -1
							return 
						end
					end
				end
			end
		end
	end
end

function limitmenu(ply,command,args)
	local plyuni = ply:UniqueID()
	if (args[1]) then
		Removeitreally(plyuni)
	end
	local rp = RecipientFilter()
	rp:AddPlayer(ply)
	for k, entclass in pairs (servertable["ply"][plyuni]["count"]["own"]["owns"]) do
		umsg.Start("Limitmenu", rp) 
			umsg.String(Translate(entclass))
			umsg.Long(servertable["ply"][plyuni]["count"]["own"]["ownamount"][k])
			umsg.Long(GetClassCount(entclass,ply,"Null"))
		umsg.End() 
	end
	umsg.Start("Limitmenu", rp)
		umsg.String("Stop")
	umsg.End()  	
end
concommand.Add("limitmenu",limitmenu) 